Skip to content

fix: handle cancelled notifications for request id zero#2116

Open
nacim-coder wants to merge 1 commit into
modelcontextprotocol:mainfrom
nacim-coder:fix-cancel-request-id-zero
Open

fix: handle cancelled notifications for request id zero#2116
nacim-coder wants to merge 1 commit into
modelcontextprotocol:mainfrom
nacim-coder:fix-cancel-request-id-zero

Conversation

@nacim-coder
Copy link
Copy Markdown

Title

fix: handle cancelled notifications for request id zero

Linked issue

Closes #2115

Summary

  • treats only an omitted requestId as missing when handling notifications/cancelled
  • preserves valid request ID 0 so the first request from a protocol instance can be cancelled
  • adds regression coverage for cancelling an in-flight request with ID 0
  • adds a patch changeset for @modelcontextprotocol/core

Validation

  • corepack pnpm install --frozen-lockfile
  • corepack pnpm --filter @modelcontextprotocol/core test -- --run packages/core/test/shared/protocol.test.ts
    Result: core test suite passed, 21 files / 553 tests
  • corepack pnpm --filter @modelcontextprotocol/core typecheck
  • corepack pnpm --filter @modelcontextprotocol/core lint
  • corepack pnpm exec prettier --check .changeset/fuzzy-birds-cancel.md

Notes

No behavior changes for other request IDs. This only avoids treating numeric ID 0 as falsy/missing.

@nacim-coder nacim-coder requested a review from a team as a code owner May 17, 2026 08:26
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 17, 2026

🦋 Changeset detected

Latest commit: a41f7c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 17, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2116

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2116

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2116

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2116

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2116

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2116

commit: a41f7c5

@BossChaos

This comment was marked as abuse.

@BossChaos

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

requestId 0 is silently dropped by _oncancel, making the first request from every Protocol uncancellable

2 participants